﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WCS.Infrastructure.Dto.Request.Coupon
{
    /// <summary>
    /// 创建优惠券模板请求对象
    /// </summary>
    public class CouponTemplateCreateRequestDto
    {
        /// <summary>
        /// 优惠券模板ID
        /// </summary>
        [StringLength(64)]
        public string? Id { get; set; }

        /// <summary>
        /// 优惠券名称
        /// </summary>
        [StringLength(64)]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 方案类型：1=消费者承担服务费，2=商家承担服务费
        /// </summary>
        public int SchemeType { get; set; }

        /// <summary>
        /// 优惠券类型：1=减免券，2=折扣券
        /// </summary>
        public int CouponType { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        public long? DiscountAmount { get; set; } = 0;

        /// <summary>
        /// 优惠折扣
        /// </summary>
        public decimal? Discount { get; set; } = 0;

        /// <summary>
        /// 使用门槛金额
        /// </summary>
        public long UseThresholdAmount { get; set; } = 0;

        /// <summary>
        /// 平台服务费率（3%-5%）
        /// </summary>
        public decimal PlatformServiceFeeRate { get; set; }

        /// <summary>
        /// 领取开始时间（用户可领取该优惠券的起始时间）
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime ReceiveStartTime { get; set; }

        /// <summary>
        /// 领取结束时间（用户可领取该优惠券的截止时间，超出则无法领取）
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime ReceiveEndTime { get; set; }

        /// <summary>
        /// 有效期类型：1=固定时间范围（所有券统一可用时间），2=领取后N小时内可用
        /// </summary>
        public int ValidityType { get; set; }

        /// <summary>
        /// 固定有效期的开始时间（当ValidityType=1时必填）
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? ValidityStartTime { get; set; }

        /// <summary>
        /// 固定有效期的结束时间（当ValidityType=1时必填）
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? ValidityEndTime { get; set; }

        /// <summary>
        /// 有效期时长（ValidityType=2时必填，单位：小时）
        /// </summary>
        public int? ValidityDuration { get; set; }

        /// <summary>
        /// 生效延迟类型：0=领取后立即生效，1=次日0点生效，2=领取后N小时生效
        /// </summary>
        public int EffectiveDelayType { get; set; }

        /// <summary>
        /// 生效延迟值（当EffectiveDelayType=2时必填，单位：小时）
        /// </summary>
        public int? EffectiveDelayValue { get; set; }

        /// <summary>
        /// 使用频率限制：1=无限制，2=每日，3=每周
        /// </summary>
        public int UseFrequencyType { get; set; }

        /// <summary>
        /// 每个周期内最大使用次数（如每日限用1次则填1）
        /// </summary>
        public int UseFrequencyLimit { get; set; }

        /// <summary>
        /// 总数量
        /// </summary>
        public int Total { get; set; }

        /// <summary>
        /// 每人最多领取数量
        /// </summary>
        public int MaxIssuePerUser { get; set; }

        /// <summary>
        /// 所属商户ID
        /// </summary>
        [StringLength(32)]
        public string MerchantId { get; set; } = null!;

        /// <summary>
        /// 所属门店ID
        /// </summary>
        [StringLength(32)]
        public string? StoreId { get; set; }


        /// <summary>
        /// 所属收款码ID
        /// </summary>
        [StringLength(32)]
        public string? CodeId { get; set; }


        /// <summary>
        /// 海报地址
        /// </summary>
        [StringLength(255)]
        public string? PosterUrl { get; set; }

        /// <summary>
        /// 扩展属性
        /// </summary>
        public string? ExtraProperties { get; set; }

        /// <summary>
        /// 模板启用状态：0=禁用,1=启用
        /// </summary>
        public int? EnableStatus { get; set; } = 1;

        /// <summary>
        /// 是否参与推送
        /// </summary>
        public bool IsPush { get; set; } = true;
    }
}
